# -*- coding: utf-8 -*-
'''
Created on 16.01.2012

@author: SkyNET
'''
import couchdb
import sys
args = sys.argv
input=args[1:]
couch=couchdb.Server("http://localhost:5984")
db=couch["users"]
in_=str(input)
in_=in_.split(" ")
try:
    name=in_[0]
    password=in_[1]
    row=[]
    map_fun='''function(doc) {if(doc.'''+name+''')  emit(doc.'''+name+''');}'''
    for row in db.query(map_fun):
        result=row.key
    if(result["password"]==password):
        print result["stack"], result["numb_game"], result["numb_win"]# ok
    else:
        print 1 # fail password
except:
    print 2 # fail